package com.yc.tomcat.impl;

import com.yc.tomcat.HttpServletRequest;
import com.yc.tomcat.HttpServletResponse;
import com.yc.tomcat.ServletException;

import java.io.IOException;
import java.io.PrintWriter;

public class GetLoginUserServlet extends HttpServletImpl{
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        PrintWriter out=response.getWriter();
        response.setContentType("application/json;charset=utf-8"); //它用来告诉服务端如何处理请求的数据 和解码格式
        Object loginUser = request.getSession().getAttribute("loginUser");
        if (loginUser!=null){
            out.println(loginUser); //以json的格式响应给浏览器
        }
    }
}
